﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BuscadorDePreco.Controls
{
    public partial class ConfirmationPopup : System.Web.UI.UserControl
    {
        public string Mensagem { get; set; }
        public string MensagemErro { get; set; }
        public string MetodoParaExclusao { get; set; }

        #region Protected Methods

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                MensagemPopup.Text = this.Mensagem;
                MensagemErroPopup.Text = this.MensagemErro;
            }
        }

        protected void ModalPopupYesBtn_Click(object sender, EventArgs e)
        {
                if(!string.IsNullOrEmpty(MetodoParaExclusao))
                    this.Page.GetType().InvokeMember(MetodoParaExclusao, System.Reflection.BindingFlags.InvokeMethod, null, this.Page, new object[] { int.Parse(ItemIdHdf.Value) });
        }

        #endregion

        #region Public Methods

        public void ShowPopup()
        {
            ModalPopupExtender_Popup.Show();
        }

        public void HidePopup()
        {
            ModalPopupExtender_Popup.Hide();
        }
   
        public void ResetPopup()
        {
            LoadingPopupDiv.Style["display"] = "none";
            MensagemDiv.Style["display"] = "block";
            ErrorDiv.Style["display"] = "none";
        }

        public void ShowError()
        {

            LoadingPopupDiv.Style["display"] = "none";
            MensagemDiv.Style["display"] = "none";
            ErrorDiv.Style["display"] = "block";
        }
        #endregion
    }
}